#include <bits/stdc++.h>
using namespace std;
int T;
int d[114514],v[114514],a[114514],p[114514];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        int n,m,L,V,ans1=0,ans2=0;
        bool xa=true,xb=true;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            if(a[i]!=0) xa=false;
            if(a[i]<0) xb=false;
        }
        for(int i=1;i<=m;i++) scanf("%d",&p[i]);
        if(xa)
        {
            for(int i=1;i<=n;i++)
            {
                if(v[i]>V&&d[i]<=p[m]) ans1++;
            }
        }
        else if(xb)
        {
            for(int i=1;i<=n;i++)
            {
                for(int j=1;j<=m;j++)
                {
                    if(p[j]>=d[i]&&sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]))>V) ans1++;
                }
            }
        }
        ans2=m-1;
        if(ans1==0) ans2=m;
        printf("%d %d\n",ans1,ans2);
    }
    return 0;
}
